import { service as request } from '@/utils/request'


/**
 * 
 * @param {*} data 
 * @returns 
 */
export function getList (data) {
  return request({
    url: `/hawk/hosts/search/cmdb/${data.page.current}/${data.page.size}`,
    method: 'post',
    data: data.query
  })
}

/**
 * 
 * @param {*} data 
 * @returns 
 */
 export function getRoomHosts (data) {
  return request({
    url: `/hawk/hosts/get/roomview/${data.page.current}/${data.page.size}/${data.roomId}`,
    method: 'get',
  })
}


/**
 * 
 * @param {*} data 
 * @returns 
 */
 export function getAllCompute (data) {
  return request({
    url: `/hawk/hosts/get/business/${data.page.current}/${data.page.size}/${data.query.businessId}`,
    method: 'get',
  })
}





// export function getList (data) {
//   return request({
//     url: `/hawk/hosts/search/cmdb/${data.page.current}/${data.page.size}`,
//     method: 'post',
//     data: data.query
//   })
// }

//用于业务系统带type,根据登录用户及主机类型获取登录用户部门的主机
// 12.5
/**
 * 
 * @param {*} data 
 * @returns 
 */
export function getHostByType (data) {
  return request({
    url: `/hawk/hosts/get/bussinessview/1/100/${data.bussId}`,
    method: 'get',
    params: data
  })
}

// 12.6 用于机房视图不带type,根据登录用户及主机类型获取登录用户部门的主机
export function getHostNoType (data) {
  return request({
    url: `/hawk/hosts/get/roomview/1/100`,
    method: 'get',
    params: data.query
  })
}


// 12.6 用于机房视图不带type,根据登录用户及主机类型获取登录用户部门的主机
export function getAll (data) {
  return request({
    url: `/hawk/hosts/get/roomview/${data.page.current}/${data.page.size}`,
    method: 'get',
    params: data.query
  })
}


//查询业务系统下的所有主机
// leo 5.4
export function getHost (data) {
  return request({
    url: `/hawk/business/get/hosts/${data.page.current}/${data.page.size}/${data.query.businessId}`,
    method: 'get',
    params:{
      ip:data.query.ip,
      name:data.query.host
    }
  })
}
export function doAdd (data) {
  return request({
    url: '/cmdb-host/',
    method: 'post',
    data
  })
}
export function doEdit (data) {
  return request({
    url: '/cmdb-host/',
    method: 'put',
    data
  })
}
export function doDelete (id) {
  return request({
    url: `/cmdb-host/${id}`,
    method: 'delete'
  })
}
export function getOne (id) {
  return request({
    url: `/cmdb-host/${id}`,
    method: 'get'
  })
}

export function getChoosedHost (data) {
  return request({
    url: `monitor/config/business/host/page/${data}`,
    method: "get"
  })
}
/**
 * 按条件查询主机
 * @param {*} tedition 
 * @param {*} tname 
 * @returns 
 */
export function search (tedition, tname) {
  return request({
    url: '/cmdb-host/pageCondition/?tedition=' + tedition + '&tname=' + tname,
    method: 'get'
  })
}
